<template>
	<view class="container" :style="`padding-top: ${barTop+barHeight}px`">
		<view class="header">
			<view class="item">
				<image src="/static/dh.png" mode="aspectFit"></image>
				<text>西安市国有资产监督管理委员会</text>
			</view>
			<view class="item">
				<image src="/static/gh.png" mode="aspectFit"></image>
				<text>西安市司法局</text>
			</view>
			<view class="item">
				<image src="/static/gh.png" mode="aspectFit"></image>
				<text>西安市信访局</text>
			</view>
		</view>
		<!-- 移除高度计算 -->
		<view class="center">
			<view class="center-top">
				<text>西安市国企退休人员信访法治化</text>
				<text>补充服务平台</text>
			</view>
			
			<view class="btns">
				<view class="btn" @click="onClickReport">
					<view class="text">
						"码"上求助
					</view>
					<view class="icon">
						<image class="safety" src="/static/help.png" mode="aspectFill"></image>
					</view>
				</view>
				<view class="btn" @click="onClickLawClassroom">
					<view class="text">
						法制讲堂
					</view>
					<view class="icon">
						<image class="safety" src="/static/classroom.png" mode="aspectFill"></image>
					</view>
				</view>
				<view class="btn" @click="onClickLawServiceCircle">
					<view class="text">
						15分钟法律服务圈
					</view>
					<view class="icon">
						<image class="safety" src="/static/serve-circle.png" mode="aspectFill"></image>
					</view>
				</view>
				<view class="btn">
					<view class="text">
						信访法治化工作法律法规指南
					</view>
					<view class="icon">
						<image class="safety" src="/static/guidebook.png" mode="aspectFill"></image>
					</view>
				</view>
			</view>
			<image class="bottom-image" src="/static/index-center-bottom.png" mode="widthFix"></image>
		</view>
	</view>
</template>

<script setup>
	import {ref} from 'vue'
	import {barHeight, barTop} from '@/utils/bar.js'
	
	/**
	 * 点击"码"上举报
	 */
	const onClickReport = () => {
		uni.navigateTo({
			url: '/pages/report-remark/report-remark'
		})
	}
	
	/**
	 * 点击15分钟法律服务圈
	 */
	const onClickLawServiceCircle = () => {
		uni.navigateTo({
			url: '/pages/lawyer/index'
		})
	}

	/**
	 * 点击法制讲堂
	 */
	const onClickLawClassroom = () => {
		console.log('点击法制讲堂');
		uni.navigateTo({
			url: '/pages/classroom/list'
		})
	}
</script>

<style lang="scss" scoped>
	.container {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		height: 100vh;
		/* 兼容 iOS 设备 */
		padding-bottom: constant(safe-area-inset-bottom);
		/* 兼容 iPhone X 及以上设备 */
		padding-bottom: env(safe-area-inset-bottom);
		// 确保padding不会使高度超出
		box-sizing: border-box;
		background:
			linear-gradient(to bottom, transparent, #eef1f4 100%),
			linear-gradient(to bottom, rgba(21, 87, 176, 1) 40%, rgba(0, 212, 255, 1));
	}

	.header {
		z-index: 10;
		width: calc(100vw - 80rpx);
		padding: 0 40rpx;
		/* 禁止收缩 */
		flex-shrink: 0;
		/* 固定高度 */
		height: 240rpx;
		display: flex;
		flex-direction: column;

		.item {
			height: 80rpx;
			display: flex;
			align-items: center;
			justify-content: center;
		}

		image {
			width: 65rpx;
			height: 65rpx;
		}

		text {
			padding-left: 10px;
			width: 500rpx;
			line-height: 100rpx;
			color: #fff;
			font-size: 32rpx;	
			font-weight: bold;
			display: inline-block;
			text-align-last: justify; //不支持IE浏览器和safari浏览器
		}
	}

	.center {
		z-index: 10;
		margin: 20rpx 0;
		/* 自动填充剩余空间 */
		flex: 1;
		/* 内容超出时滚动 */
		overflow: auto;
		border-radius: 20rpx;
		overflow: hidden;
		background-color: #fff;
		// border: 1px solid red;
		width: calc(100vw - 100rpx);
		display: flex;
		flex-direction: column;
		justify-content: space-between;
		position: relative;
		
		.center-top {
			width: 100%;
			height: 200rpx;
			display: flex;
			flex-direction: column;
			align-items: center;
			justify-content: center;
			font-size: 40rpx;
			font-weight: bold;
			
			text {
				padding: 6rpx 0;
			}
		}
		
		.bottom-image {
			width: 100%;
			position: absolute;
			z-index: -1;
			bottom: 0;
		}
		
		.btns {
			padding: 0 10% 30rpx;
			width: 80%;
			flex: 1;
			display: flex;
			flex-direction: column;
			justify-content: space-around;
			
			.btn {
				box-sizing: border-box;
				padding: 0 20rpx;
				width: 100%;
				height: 180rpx;
				border-radius: 20rpx;
				box-shadow: 2px 2px 2px 2px rgba(0, 0, 0, 0.4);
				display: flex;
				align-items: center;
				justify-content: space-between;
				background-color: rgba(47, 128, 237, 0.9);
				
				.text {
					flex: 1;
					font-size: 40rpx;
					font-weight: bold;
					color: #fff;
					text-align: center;
					letter-spacing: 2rpx;
				}
				
				.icon {
					flex: 0 0 120rpx;
					width: 120rpx;
					height: 120rpx;
					position: relative;
					
					.scan {
						position: absolute;
						width: 120rpx;
						height: 120rpx;
						top: 0;
						left: 0;
					}
					
					.safety,.inspector {
						position: absolute;
						width: 60rpx;
						height: 60rpx;
						top: 30rpx;
						left: 32rpx;
					}
				}
			}
		}
	}
</style>